<?php
declare (strict_types = 1);

namespace app\move;


use app\api\model\Category;
use app\BaseController;
use app\homl\model\User;
use app\services\TreeService;
use think\facade\View;

/**
 * 控制器基础类
 */
class MoveController extends BaseController
{
    public function initialize(){
        if(cookie('uid')){
            if(!session('userInfo')){
                $userInfo=User::find(cookie('uid'));
                session('userInfo',$userInfo->toArray());
            }
        }
        //获取商品分类信息
        $categors=Category::order('sort','asc')->field('id,pid,cate_name')->select();
//        dd($categors->toArray());
        $categorsAll=TreeService::getTreeChildren($categors->toArray());
        View::assign('categorsAll',$categorsAll);
    }


}
